home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / tempconv.lha / tempconv.b < prev    next >
Text File  |  1995-11-18  |  826b  |  55 lines

  1. /*Fahrenheit<->Celsius converter*/
  2.  
  3. DIM y$(5)
  4.  
  5. for x=1 to ARGCOUNT
  6.         y$(x)=UCASE$(ARG$(x))
  7. next x
  8.  
  9. z$=RIGHT$(y$(1),1)
  10.  
  11. if z$<> "C" AND z$<>"F" goto usage
  12.  
  13. w=LEN(y$(1))-1
  14.  
  15. if w=0 goto usage
  16.  
  17. v$=LEFT$(y$(1),w)
  18.  
  19. for i=1 to (w)
  20.         if ASC(MID$(v$,i,1))<48 or ASC(MID$(v$,i,1))>57 then
  21.                 print "Invalid argument."
  22.                 goto usage
  23.         end if
  24. next i
  25.  
  26. u=VAL(v$)
  27.  
  28. if z$="C" goto c2f
  29.  
  30. t=(u-32)/9*5
  31. a$=STR$(t)+"C"
  32. goto qt
  33.  
  34. c2f:
  35.  t=u*1.8+32
  36.  a$=STR$(t)+"F"
  37.  
  38. qt:
  39.  ans$=y$(1)+" = "+a$
  40.  print ans$
  41.  end
  42.  
  43. usage:
  44.  print "tempconv <temp>"
  45.  print " "
  46.  print "temp should be a numeric argument"
  47.  print "followed by an F for fahrenheit"
  48.  print "temps to be converted to celsius"
  49.  print "or by a C for celsius temps to be"
  50.  print "converted to fahrenheit."
  51.  print " "
  52.  print "©1995 William F. Maddock"
  53.  stop
  54.  
  55.